home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Environments / PowerMacOberon feb96 / Text / Toolbox.Interface.Text (.txt) < prev    next >
Encoding:
Oberon Text  |  1994-11-18  |  5.2 KB  |  80 lines  |  [TEXT/.Ob4]

  1. Syntax10.Scn.Fnt
  2. ParcElems
  3. Alloc
  4. Syntax20.Scn.Fnt
  5. Syntax12.Scn.Fnt
  6. Syntax14.Scn.Fnt
  7. Syntax14b.Scn.Fnt
  8. Syntax12i.Scn.Fnt
  9. Syntax12b.Scn.Fnt
  10. GraphicElems
  11. Alloc
  12. Elektra24.Scn.Fnt
  13. Syntax10.Scn.Fnt
  14. R3 (par 0)
  15. R10 (par 7)
  16. -- alignment --
  17. saved registers
  18. and local variables
  19. output parameter area
  20. (normally empty)
  21. PC saved by callee
  22. The toolbox interface and the module SYSTEM
  23.  M. Hof, November 18, 1994
  24.  The Toolbox Interface
  25. PowerMac Oberon offers a module Sys which exports the most frequently used types, variables, and procedures of the Macintosh toolbox. Additional toolbox interfaces can be implemented on demand, as described in this text.
  26. Toolbox constants, variables, and types can be declared as described in Inside Macintosh. Records, however, must be aligned according to the 68K conventions (2 byte boundaries) instead of the PowerPC conventions (4 byte boundaries). Therefore, toolbox records have to be declared with a special alignment option, e.g.:
  27.     TYPE
  28.         Point = RECORD [Sys.align68K]
  29.             v, h: INTEGER;
  30.         END;
  31. To write an interface to a toolbox procedure, you have to do the following:
  32. a)    Declare a procedure variable with the interface as described in Inside Macintosh, e.g.:
  33.         VAR GetMouse: PROCEDURE (mouseLoc: Point);
  34. b)    Initialize the procedure variable with the corresponding procedure from the toolbox library. This can be done using the procedure Sys.Assign, e. g.: 
  35.         Sys.Assign("GetMouse", SYSTEM.ADR(GetMouse)); ASSERT(GetMouse # NIL)
  36.     The first parameter of Assign is the name of the toolbox procedure the second parameter is the address of the procedure variable to be initialized.
  37. Caution
  38. -    Never use a record as VAR-Parameter. Always pass records as a VAL-Parameter.
  39. -    Pointers returned by the toolbox must not be saved into Oberon pointer variables, but should be casted to a LONGINT. Otherwise, the garbage collector will start collecting memory in your toolbox.
  40. The following example shows a complete module that uses the toolbox procedure GetMouse.
  41.     MODULE Mouse;
  42.     IMPORT Sys, SYSTEM;
  43.     TYPE
  44.         Point = RECORD [Sys.align68K]
  45.             v, h: INTEGER
  46.         END;
  47.         GetMouse: PROCEDURE (mouseLoc: Point);
  48.     PROCEDURE GetMousePos* (VAR x, y: INTEGER);
  49.         VAR p: Point;
  50.     BEGIN
  51.         GetMouse (p);
  52.         x := p.h; y := p.v
  53.     END GetMousePos;
  54.     BEGIN
  55.         Sys.Assign ("GetMouse", SYSTEM.ADR (GetMouse));
  56.         ASSERT (GetMouse # NIL)
  57.     END Mouse.
  58. Module SYSTEM
  59. Module SYSTEM allows the user to break the Oberon type rules and to access machine dependent information. Under PowerMac Oberon, SYSTEM includes the procedures defined in the Oberon report in addition to PowerPC specific procedures:
  60. -    SYSTEM.GETREG(n, v) reads register n into the variable v. n must be a constant expression in the range 0..66. The type of v must be a basic type, a pointer or a procedure type. Registers 48 .. 66 can only be read in supervisor mode.
  61. -    SYSTEM.PUTREG(n, e) writes expression e to register n. n must be a constant expression in the range 0..66. The type of e must be a basic type, a pointer or a procedure type. Registers 48 .. 66 can only be written in supervisor mode.
  62. Register numbers
  63. General purpose registers (0..31)
  64.     0..31    Rx or FPx, depending on the second operand of GETREG or PUTREG
  65.     1    SP (stack pointer)
  66.     2    SB (static base)
  67.     31    FP (frame pointer)
  68. Control registers (32..66; 48..66 are priviledged)
  69.     32    MQ (multiplier quotient register)
  70.     33    XER (integer exception register)
  71.     36    fromRTCU (real time clock upper)
  72.     37    fromRTCL (realtime clock lower)
  73.     38    fromDEC (decrement register)
  74.     40    LR (link register)
  75.     41    CTR (count register)
  76.     64    CR (control register)
  77.     65    MSR (machine state register)
  78.     66    FPSCR (FP status and control register)
  79. Layout of a stack frame
  80.